namespace CodeConsult.Nordic.nRF8001.ApplicationControlInterface.Events.SystemEvents
{
    public class ConnectedEvent : AciEventBase
    {
        public const byte OpCode = 0x85;
 
        public byte AddressType { get; set; }
        public byte[] PeerAddress { get; set; }
        public ushort ConnectionInterval { get; set; }
        public ushort SlaveLacency { get; set; }
        public ushort SupervisionTimeout { get; set; }
        public byte MasterClockAccuracy { get; set; }

        protected override void DecodeFromBuffer()
        {
            AddressType = DecodeHelper.GetByte();
            PeerAddress = DecodeHelper.GetBytes(6);
            ConnectionInterval = DecodeHelper.GetUnsignedShort(DecodeHelper.ByteOrder.LsbMsb);
            SlaveLacency = DecodeHelper.GetUnsignedShort(DecodeHelper.ByteOrder.LsbMsb);
            SupervisionTimeout = DecodeHelper.GetUnsignedShort(DecodeHelper.ByteOrder.LsbMsb);
            MasterClockAccuracy = DecodeHelper.GetByte();
        }
    }
}
